package com.zhiyizhen.handheld.common;

import android.text.TextUtils;

import com.zhiyizhen.handheld.component.main.bean.EnumFieldBean;
import com.zhiyizhen.handheld.component.main.bean.EnumsBean;
import com.zhiyizhen.handheld.component.main.bean.ExecTypeBean;

import java.util.List;

public class StringUtil {

    public static String getGender(String gender, EnumsBean enumsBean) {
        if (enumsBean == null || enumsBean.getEnums() == null) {
            return "未知";
        }
        List<EnumFieldBean> sexEnum = enumsBean.getEnums().getSexEnum();
        for (int i = 0; i < sexEnum.size(); i++) {
            if (TextUtils.equals(sexEnum.get(i).getValue(), gender)) {
                return sexEnum.get(i).getText();
            }
        }
        return "未知";
    }

    public static String getAge(String year, String month) {
        if (TextUtils.isEmpty(year) && TextUtils.isEmpty(month)) {
            return "未知";
        }
        if (TextUtils.isEmpty(year)) {
            return month + "个月";
        }
        if (TextUtils.isEmpty(month)) {
            return year + "岁";
        }
        return year + "岁" + month + "个月";
    }

    public static String getExecuteType(List<ExecTypeBean> typeBeans, String typeValue) {
        if (typeBeans == null || TextUtils.isEmpty(typeValue)) {
            return "未知";
        }
        for (int i = 0; i < typeBeans.size(); i++) {
            if (TextUtils.equals(typeValue, typeBeans.get(i).getItemCode())) {
                return typeBeans.get(i).getItemName();
            }
        }
        return "未知";
    }

    public static String getDripRate(String typeValue) {
        if (TextUtils.isEmpty(typeValue)) {
            return "未知";
        }
        List<EnumFieldBean> infusionIvDripRateEnum = DataCache.getEnumsBean().getEnums().getInfusionIvDripRateEnum();
        if (infusionIvDripRateEnum == null) {
            return "未知";
        }

        for (int i = 0; i < infusionIvDripRateEnum.size(); i++) {
            if (TextUtils.equals(typeValue, infusionIvDripRateEnum.get(i).getValue())) {
                return infusionIvDripRateEnum.get(i).getText();
            }
        }
        return "未知";
    }
}
